import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Random;

public class text {


    public static long sum1=0;
    public static long sum2=0;
    public static void init(int[]arr)
    {
        Random b=new Random();

        int i=0;
        for(i=0;i<10000000;i++)
        {
            arr[i]=b.nextInt(100)+1;
        }
    }



    public static void count()
    {
        int[]arr=new int[10000000];
        Thread thread1=new Thread(new Runnable() {
            @Override
            public void run() {
                int i=0;
                for(i=0;i<10000000;i++)
                {
                    if(i%2==0)
                    {
                        sum1+=arr[i];

                    }

                }

            }
        });
        Thread thread2=new Thread(new Runnable() {
            @Override
            public void run() {
                int i=0;
                for(i=0;i<10000000;i++)
                {
                    sum2+=arr[i];
                }

            }
        });
        //int[]arr=new int[10000000];
        init(arr);

        long start=System.currentTimeMillis();
        thread1.start();
        thread2.start();
        try {
            thread1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try
        {
            thread2.join();
        } catch(InterruptedException e)
        {
            throw new RuntimeException();

        }
        long end=System.currentTimeMillis();
        System.out.println(sum1+sum2);
        System.out.println(end-start);

    }
    public static void main2(String[] args) {
        count();

    }


    public static void main(String[] args) {

        Thread thread1=new Thread(new Runnable() {
            @Override
            public void run() {
                long d=0;
               long i=0;
               for(i=0;i<100_0000_0000L;i++) {
                   d++;


               }
            }
        });
        Thread thread2=new Thread(new Runnable() {
            @Override
            public void run() {

                long c=0;
                long k=0;
                for(c=0;c<100_0000_0000L;c++)
                {
                    k++;
                }

            }
        });
        long beg=System.currentTimeMillis();
        thread1.start();
        thread2.start();
        try {
            thread1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            thread2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        long end=System.currentTimeMillis();
        System.out.println(end-beg);



    }
}
